<template>
  <div
      v-if="orgVisible"
  >
    <micro-app-approval
        v-if="orgVisible"
        router-mode="state"
        name="allComponents1"
        :url="
              isProduction
                ? `${locationUrl}/micro_apps/${appMenu.app}/`
                : devHttpMap[currentAppName]
            "
        :default-page="`#/${routeName}`"
        :data="$utils.getAppToChildData(  {})"
        @datachange="handleComponentsChange"
        @unmount="onUnmountChange"
        @mounted='onCreatedChange'
    ></micro-app-approval>
  </div>
  <div v-else style="height: 100%;line-height: 100%;text-align: center">
     加载中
  </div>
</template>

<script>
import utils from "../../common/utils/utils";
import {nextTick, reactive, toRefs,watch} from 'vue'
import {useRoute} from "vue-router";
export default {
  name:"orgCommon",
  setup(props,context) {

    const state = reactive({
      currentAppName:" ",
      orgVisible:false,
      routeName:"",

    })

    const $route = useRoute()

    const init = () => {
      console.log($route.query)
      state.routeName = $route.query.routeName
      state.currentAppName="org";
      state.orgVisible=true
    }


    const handleComponentsChange = (e) => {

      const data = e?.detail?.data;
      if (data.type == 'close') {
        nextTick(()=>{
          state.orgVisible=false
          state.currentAppName=" ";
          state.tableLoading=false
        })
      }
    };
    const onUnmountChange =(e)=>{
      console.log('卸载1111111111111111111111',e)
    }
    const  onCreatedChange =()=>{
      console.log('加载··············')
    }

    init()


    const devHttpMap = {
      org: "http://localhost:4001/",
    }
    return {
      ...toRefs(state),
      handleComponentsChange,
      onCreatedChange,
      onUnmountChange,
      devHttpMap,


    }
  }
}
</script>

<style lang="less" scoped>

</style>